package com.crm.action;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.crm.po.Config;
import com.crm.service.ConfigService;
import com.crm.util.ResponseUtils;

public class ConfigAction extends Servlet {

	private static final long serialVersionUID = 1116994082953057010L;
	
	public void getConList(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		ConfigService service = new ConfigService();
		 List<Config> list = service.getConList();		
		ResponseUtils.printJson(response, null, list, null,null);
	}
	
	public void getConfig(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		ConfigService service = new ConfigService();

		Config config = service.getConfig(request);
	
		ResponseUtils.printJson(response, null, config, null,null);
	}
	
	public void saveOrUpdatecon(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		ConfigService service = new ConfigService();

		boolean result = service.exeSystemConfig(request);
	
		String value = result ? "ok": "系统配置失败，请检查您的系统是否出现错误。";
		ResponseUtils.printString(response, value);
	}

}
